using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ParameterObject : System.Web.UI.Page
{
    GridView gridView;
    SqlDataSource sqlDataSource;
    protected void Page_Load(object sender, EventArgs e)
    {
        sqlDataSource = new SqlDataSource();
        sqlDataSource.ConnectionString =
        WebConfigurationManager.ConnectionStrings[
            "RecruitVietnamDbConnectionString"
            ].ConnectionString;
        sqlDataSource.SelectCommandType =
        SqlDataSourceCommandType.Text;
        gridView = new GridView();
        this.form1.Controls.Add(gridView);
        AddParameterByParameterObject("Ho Chi Minh");
    }

     

    void AddParameterByParameterObject(string cityName)
    {        
        sqlDataSource.SelectCommand =
        "select UserID,Email, FirstName," +
        "LastName,City,LastLogin from tblJSAccounts " +
        " where City=@City ";
        Parameter parameter = new        
        Parameter("City", TypeCode.String, cityName);        
        sqlDataSource.SelectParameters.Add(parameter);
       
        gridView.DataSource = sqlDataSource;
        gridView.DataBind();

    }
}
